#!/bin/sh
if [ $# -lt 1 ]; then
	echo 'USAGE : $0 className [line type]'
	exit 1
fi

TYPE="linespoints"

if [ $# -eq 2 ]; then
	TYPE=$2
fi

CLASS=$1
echo "${CLASS}.java compilation"
javac ${CLASS}.java

echo "${CLASS}.class computation"
java ${CLASS} > data.gnuplot

echo "${CLASS} Command generation"
echo "plot \"data.gnuplot\" using 1:2 title \"${CLASS}\" with $TYPE" > ${CLASS}Command

echo "${CLASS} data drawing"
gnuplot -persist ${CLASS}Command

rm -fr ${CLASS}Command
rm -fr data.gnuplot
